<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<center>
	    <div style="background: #BEEBEB; width: 100%; font-family: '微软雅黑';">
		<div style="text-align: center; font-size: 24px;">考试记录</div>
	</div>
	</center>
		<table width="100%" border="1" align="center" bgcolor="#BEEBEB" cellpadding="0" cellspacing="0">
			<tr>
			    <th colspan="7">
				<form action="javascript:submit()" id='form' method="post">
				状&nbsp;&nbsp;态:<input id="isPass" name="isPass" type="text"/>&nbsp;
				试卷名称:<input  id="paperName" name="paperName" type="text"/>&nbsp;
				<input type="submit" value="查询"/>
		        </form>
			    </th>
			</tr>
			<tr>
				<th>序号</th>
				<th>试卷名称</th>
				<th>开始时间</th>
				<th>提交时间</th>
				<th>总分数</th>
				<th>得分数</th>
				<th>是否通过</th>
			</tr>
			
			<c:forEach items="${exModel.list }" var="record" varStatus="v">
				<tr>
					<td scope="row">${v.count + (exModel.pageNo - 1) * exModel.pageSize}</td>
					<td>${record.paperName }</td>
					<td><fmt:formatDate value="${record.startTime }" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
					<td><fmt:formatDate value="${record.submitTime }" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
					<td>${record.totalPoint }</td>
					<td>${record.getPoint }</td>
					<td>
					 	<c:if test="${record.isPass == 1 }">通过</c:if>
					 	<c:if test="${record.isPass == 2 }">未通过</c:if>
					 	<c:if test="${record.isPass == 3 }">超时未提交</c:if>
					</td>
				</tr>
			</c:forEach>
			<tr>
						<td colspan="7" align="right">
							<a id="first" href="javascript:changepage('<%=request.getContextPath() %>/stu/ExamRecordServlet?command=list&pageNo=1')">首页</a>&nbsp;
							<a id="pre" href="javascript:changepage('<%=request.getContextPath() %>/stu/ExamRecordServlet?command=list&pageNo=${exModel.pre}')">上一页</a>&nbsp;
							第<select onchange="goPage(this)">
								<script>
									var pageNo = '${exModel.pageNo}';
									var totalPage = '${exModel.last }';
									for (var i = 1; i <= totalPage; i++) {
										if (pageNo == i) {
											document.write('<option value="' + i + '" selected="selected">' + i + '</option>');
										} else {
											document.write('<option value="' + i + '">' + i + '</option>');
										}
									}
								</script>
							 </select>页
							,共${pageModel.totalPage}页&nbsp;
							<a id="next" href="javascript:changepage('<%=request.getContextPath() %>/stu/ExamRecordServlet?command=list&pageNo=${exModel.next}')">下一页</a>&nbsp;&nbsp;
							<a id="last" href="javascript:changepage('<%=request.getContextPath() %>/stu/ExamRecordServlet?command=list&pageNo=${exModel.last}')">尾页</a>
							共${exModel.last}条记录
						</td>
					</tr>
		</table>
		
		<%-- <div   style = 'float: right;'> 
		<a id="first" href="javascript:changepage('<%=request.getContextPath() %>/stu/ExamRecordServlet?command=list&pageNo=1')">首页</a>&nbsp;&nbsp;
		<a id="pre" href="javascript:changepage('<%=request.getContextPath() %>/stu/ExamRecordServlet?command=list&pageNo=${exModel.pre}')">上一页</a>&nbsp;&nbsp;
		<span>现在是第${exModel.pageNo}页</span>&nbsp;&nbsp;
		<a id="next" href="javascript:changepage('<%=request.getContextPath() %>/stu/ExamRecordServlet?command=list&pageNo=${exModel.next}')">下一页</a>&nbsp;&nbsp;
		<a id="last" href="javascript:changepage('<%=request.getContextPath() %>/stu/ExamRecordServlet?command=list&pageNo=${exModel.last}')">尾页</a>

	 <p>共有${exModel.last }页</p>
	   </div> --%>
	<script>
		var ispass ='${isPass}';
		var isPass = document.getElementById("isPass");
		isPass.value = ispass;
		
		var papername = '${paperName}';
		var paperName = document.getElementById("paperName");
		paperName.value = papername;
	</script>
	
	
	<script>
		function changepage(url){
			var form = document.getElementById("form");
			form.action = url;
			form.submit();
		}
		function submit(){
			var paperName=document.getElementById("paperName");
			var isPass=document.getElementById("isPass");
            location='<%=request.getContextPath()%>/stu/ExamRecordServlet?command=list&paperName='+paperName.value+'&isPass='+isPass.value;
				
		}
	</script>
</body>
</html>